home *** CD-ROM | disk | FTP | other *** search
/ Amiga CD-Sensation: Golden Games / Amiga CD-Sensation - Ausgabe 2 - Golden Games (1996)(GTI - Schatztruhe)(DE)[!].iso / Brain Activity / Conquest / Conquest.mod < prev    next >
Text File  |  1992-12-20  |  51KB  |  1,736 lines

  1. MODULE Conquest;
  2.  
  3.  
  4.  
  5. IMPORT
  6.   DosD,DosL,
  7.   MLL:MathLibLong,
  8.   RN:RandomNumber,
  9.   Storage,
  10.   SYSTEM;
  11.  
  12.  
  13.  
  14. FROM Conquest2
  15.   IMPORT
  16.     ambCost,bdsize,board,battleShipCost,battleShipGuns,
  17.     bExploreProb,bExploreVar,blankLine,cExploreProb,cExploreVar,
  18.     colStars,cruiserCost,cruiserGuns,curRange,cursor,distance,
  19.     enemyArrival,enemyDepart,enemyResearch,gameOver,
  20.     growthRate,initgrowthenemy,initgrowthplayer,initmoney,
  21.     initrange,initunit,initvel,initweap,IntType,investCost,
  22.     iuRatio,left,Line,maxRange,maxVelocity,maxWeapons,
  23.     maxTurns,mbCost,min,nstars,Planet,PlanetPtr,playerArrival,
  24.     prodYear,rangeRequired,rangeResearch,rawFile,
  25.     RealStarList,resCostFactor,right,scoutCost,sExploreProb,
  26.     sExploreVar,Star,StarList,stars,TaskForce,Team,
  27.     tExploreProb,tExploreVar,tf,tfStars,turn,vel,
  28.     velocityRequired,velocityResearch,weaponRequired,
  29.     weaponResearch,weapons,
  30.  
  31.     AnyWarShip,CheckGameOver,ClearField,ClearLeft,ClearScreen,
  32.     CursorOff,CursorOn,DisplayForces,DisplayTF,DoResearch,
  33.     EnemyAttack,ErrorMessage,FindBestPlan,GetChar,GetLine,
  34.     GetStars,GetTF,GetToken,Help,JoinSilent,JoinTF,Lose,MakeTF,
  35.     OnBoard,Pause,PlayerAttack,PrintColony,PrintMap,
  36.     PrintPlanet,PrintStar,PrintTF,PutCh,PutInt,PutStr,
  37.     ResearchSummary,Revolt,SetCursorPos,SetDestination,
  38.     StarSummary,TFBattle,TFSummary,UpdateBoard,WithDraw,ZeroTF;
  39.  
  40.  
  41.  
  42. VAR
  43.   vers: ARRAY[0..80] OF CHAR;
  44.  
  45.  
  46.  
  47. CONST
  48.   version="\o$VER: Conquest 2.3 (20-DEC-92) (PD) JOW\o";
  49.  
  50.  
  51.  
  52. PROCEDURE NextYear;
  53.   BEGIN
  54.     INC(turn);
  55.     INC(prodYear);
  56.     SetCursorPos(31,18);
  57.     PutStr(" Year              ");
  58.     SetCursorPos(37,18);
  59.     PutInt(turn,3);
  60.     SetCursorPos(31,19);
  61.     PutStr(" Production year   ");
  62.     SetCursorPos(48,19);
  63.     PutInt(prodYear,1);
  64.   END NextYear;
  65.  
  66.  
  67.  
  68. PROCEDURE NewPlanet(VAR x: PlanetPtr);
  69.   BEGIN
  70.     Storage.ALLOCATE(x,SIZE(Planet));
  71.   END NewPlanet;
  72.  
  73.  
  74.  
  75. PROCEDURE Battle;
  76.   VAR
  77.     first: BOOLEAN;
  78.     starnum: IntType;
  79.   BEGIN
  80.     first:=TRUE;
  81.     FOR starnum:=1 TO nstars DO
  82.       IF (tfStars[starnum][ENEMY]>0)  AND
  83.          (tfStars[starnum][player]>0) AND
  84.          (AnyWarShip(ENEMY, starnum) OR AnyWarShip(player, starnum)) THEN
  85.         IF first THEN
  86.           SetCursorPos(32,20);
  87.           PutStr("* Taskforce battle *");
  88.           first:=FALSE;
  89.         END;
  90.         TFBattle(starnum);
  91.       END;
  92.       IF (AnyWarShip(ENEMY,starnum)) AND (colStars[starnum][player]>0) THEN
  93.         EnemyAttack(starnum);
  94.       ELSIF (tfStars[starnum][player]>0) AND (colStars[starnum][ENEMY]>0) THEN
  95.         PlayerAttack(starnum);
  96.       END;
  97.     END;
  98.   END Battle;
  99.  
  100.  
  101.  
  102. PROCEDURE BlastPlanet(VAR star: Star; planet: PlanetPtr; factors: IntType);
  103.   VAR
  104.     killed: IntType;
  105.     prev,curr: PlanetPtr;
  106.     done: BOOLEAN;
  107.   BEGIN
  108.     killed:=min(planet^.capacity,factors DIV 4);
  109.     planet^.inhabitants:=min(planet^.inhabitants,planet^.capacity)-killed;
  110.     planet^.iu:=min(planet^.iu-killed,planet^.inhabitants*iuRatio);
  111.     planet^.capacity:=planet^.capacity-killed;
  112.     IF planet^.inhabitants<=0 THEN
  113.       planet^.inhabitants:=0;
  114.       planet^.iu:=0;
  115.       planet^.mb:=0;
  116.       planet^.amb:=0;
  117.       IF planet^.team#none THEN
  118.         DEC(colStars[planet^.pstar][planet^.team]);
  119.         planet^.team:=none;
  120.         planet^.eSeeTeam:=none;
  121.         planet^.conquered:=FALSE;
  122.         OnBoard(stars[planet^.pstar].x,stars[planet^.pstar].y);
  123.       END;
  124.       IF planet^.capacity<=0 THEN
  125.         IF planet=star.firstPlanet THEN
  126.           star.firstPlanet:=planet^.next;
  127.           Storage.DEALLOCATE(planet,SIZE(Planet));
  128.         ELSE
  129.           prev:=star.firstPlanet;
  130.           curr:=star.firstPlanet^.next;
  131.           done:=FALSE;
  132.           REPEAT
  133.             IF curr=planet THEN
  134.               prev^.next:=curr^.next;
  135.               Storage.DEALLOCATE(curr,SIZE(Planet));
  136.               done:=TRUE;
  137.             ELSE;
  138.               prev:=curr;
  139.               curr:=curr^.next;
  140.             END;
  141.           UNTIL (curr=NIL) OR done;
  142.         END;
  143.       END;
  144.     END;
  145.   END BlastPlanet;
  146.  
  147.  
  148.  
  149. PROCEDURE AssignPlanets(VAR ustar: Star;
  150.                         starnum: IntType;
  151.                         psize: CHAR);
  152.   VAR
  153.     i1,nplanets: IntType;
  154.     pplanet: PlanetPtr;
  155.   BEGIN
  156.     nplanets:=RN.RND(2+((INTEGER(psize)-48+1) DIV 2));
  157.     IF (RN.RND(5)<=INTEGER(psize)-48) AND (nplanets>0) THEN
  158.       INC(nplanets);
  159.     END;
  160.  
  161.     IF nplanets<=0 THEN
  162.       ustar.firstPlanet:=NIL;
  163.     ELSE
  164.       NewPlanet(pplanet);
  165.       ustar.firstPlanet:=pplanet;
  166.       FOR i1:=1 TO nplanets DO
  167.         pplanet^.number:=i1;
  168.         IF (RN.RND(10)>3) AND ((pplanet^.number>2) OR (nplanets=1)) THEN
  169.           CASE psize OF
  170.             |"1": pplanet^.capacity:=10*(RN.RND(5)+2);
  171.             |"2": pplanet^.capacity:=10*(RN.RND(10)+3);
  172.             |"3": pplanet^.capacity:=10*(RN.RND(13)+4);
  173.             |"4": pplanet^.capacity:=10*(RN.RND(14)+5);
  174.             |"5": pplanet^.capacity:=20*(RN.RND(15)+6);
  175.           END;
  176.         ELSE
  177.           CASE psize OF
  178.             |"1": pplanet^.capacity:=5*RN.RND(4)+5;
  179.             |"2": pplanet^.capacity:=5*RN.RND(6)+5;
  180.             |"3": pplanet^.capacity:=5*RN.RND(8)+10;
  181.             |"4": pplanet^.capacity:=5*RN.RND(10)+15;
  182.             |"5": pplanet^.capacity:=10*RN.RND(10)+20;
  183.           END;
  184.         END;
  185.         pplanet^.pSeeCapacity:=pplanet^.capacity;
  186.         pplanet^.team:=none;
  187.         pplanet^.inhabitants:=0;
  188.         pplanet^.iu:=0;
  189.         pplanet^.mb:=0;
  190.         pplanet^.amb:=0;
  191.         pplanet^.conquered:=FALSE;
  192.         pplanet^.underAttack:=FALSE;
  193.         pplanet^.eSeeTeam:=none;
  194.         pplanet^.eSeeDefend:=1;
  195.         pplanet^.pstar:=starnum;
  196.         IF i1=nplanets THEN
  197.           pplanet^.next:=NIL;
  198.         ELSE
  199.           NewPlanet(pplanet^.next);
  200.           pplanet:=pplanet^.next;
  201.         END;
  202.       END;
  203.     END;
  204.   END AssignPlanets;
  205.  
  206.  
  207.  
  208. PROCEDURE InitPlayer;
  209.   VAR
  210.     str,key: CHAR;
  211.     starNum: IntType;
  212.     balance,cost,amt,ind: IntType;
  213.     iline: Line;
  214.   BEGIN
  215.     REPEAT
  216.       SetCursorPos(1,18);
  217.       PutStr("start at star?\n     ");
  218.       GetChar(str);
  219.       SetCursorPos(1,19);
  220.       starNum:=IntType(str)-IntType("A")+1;
  221.     UNTIL (starNum>=1) AND (starNum<=nstars);
  222.  
  223.     tf[player][1].x:=stars[starNum].x;
  224.     tf[player][1].y:=stars[starNum].y;
  225.     tfStars[starNum][player]:=1;
  226.     tf[player][1].dest:=starNum;
  227.     SetCursorPos(1,20);
  228.     PutStr("choose your initial fleet.");
  229.     SetCursorPos(1,21);
  230.     PutStr("you have "); PutInt(initunit,0);
  231.     PutStr(" transports");
  232.     SetCursorPos(1,22);
  233.     PutStr(" and "); PutInt(initmoney,0);
  234.     PutStr(" units to spend");
  235.     SetCursorPos(1,23);
  236.     PutStr("on ships or research.");
  237.     balance:=initmoney;
  238.     ResearchSummary;
  239.     REPEAT
  240.       SetCursorPos(1,19);
  241.       PrintTF(1);
  242.       SetCursorPos(1,18);
  243.       PutInt(balance,3); PutStr("?                          ");
  244.       SetCursorPos(6,18);
  245.       GetLine(iline,ind,FALSE);
  246.       REPEAT
  247.         GetToken(iline,ind,amt,key);
  248.         CASE key OF
  249.           |"C": cost:=amt*cruiserCost;
  250.                 IF cost<=balance THEN
  251.                   tf[player][1].c:=tf[player][1].c+amt;
  252.                 END;
  253.           |"S": cost:=amt*scoutCost;
  254.                 IF cost<=balance THEN
  255.                   tf[player][1].s:=tf[player][1].s+amt;
  256.                 END;
  257.           |"B": cost:=amt*battleShipCost;
  258.                 IF cost<=balance THEN
  259.                   tf[player][1].b:=tf[player][1].b+amt;
  260.                 END;
  261.           |"H": Help(0);
  262.                 cost:=0;
  263.           |"W",
  264.            "V",
  265.            "R": cost:=amt;
  266.                 IF cost<=balance THEN
  267.                   DoResearch(player,key,amt);
  268.                 END;
  269.                 ResearchSummary;
  270.           |" ": cost:=0;
  271.           |">": SetCursorPos(1,18);
  272.                 PutStr(">?      ");
  273.                 SetCursorPos(4,18);
  274.                 cost:=0;
  275.                 GetChar(key);
  276.                 CASE key OF
  277.                   |"M": PrintMap;
  278.                   |"R": ResearchSummary;
  279.                   |ELSE ErrorMessage;
  280.                         PutStr(" !only M,R during initialize");
  281.                 END;
  282.           |ELSE ErrorMessage;
  283.                 PutStr( " !Illegal field "); PutCh(key);
  284.         END;
  285.  
  286.         IF cost<=balance THEN
  287.           balance:=balance-cost;
  288.         ELSE
  289.           ErrorMessage();
  290.           PutStr("  !can't afford "); PutCh(key);
  291.         END;
  292.       UNTIL key=" ";
  293.     UNTIL balance<=0;
  294.     stars[starNum].visit[player]:=TRUE;
  295.     board[stars[starNum].x][stars[starNum].y].tf:='a';
  296.     board[stars[starNum].x][stars[starNum].y].enemy:=' ';
  297.     OnBoard(stars[starNum].x,stars[starNum].y);
  298.     SetCursorPos(32,20);
  299.   END InitPlayer;
  300.  
  301.  
  302.  
  303. PROCEDURE InitConstants;
  304.   VAR
  305.     i3,i1,i2,x,y,temp: IntType;
  306.     team: Team;
  307.     tt: CHAR;
  308.     date: DosD.Date;
  309.     ch: CHAR;
  310.     level: CHAR;
  311.     planetsize: CHAR;
  312.     randomEnemy: BOOLEAN;
  313.   BEGIN
  314.     PutStr("\n* Welcome to CONQUEST! *\n\n");
  315.     PutStr("Amiga version 2.3\n");
  316.     PutStr("Original author (UNIX) unknown\n");
  317.     PutStr("Original Amiga port by Bob Shimbo\n");
  318.     PutStr("Enhanced Amiga version by JOW (based on the release on Fish #24)\n\n");
  319.     PutStr("Original Copyright unknown, this version is PD (without restrictions)\n\n");
  320.  
  321.     PutStr("level 1=easy, 2=medium, 3=hard (default=2)? ");
  322.     GetChar(level);
  323.     IF level#"\n" THEN
  324.       PutCh("\n");
  325.     END;
  326.     IF (level#"1") AND (level#"3") THEN
  327.       level:="2";
  328.     END;
  329.  
  330.     DosL.DateStamp(SYSTEM.ADR(date));
  331.     RN.PutSeed(date.tick);
  332.  
  333.     (* init the board *)
  334.     FOR i1:=1 TO bdsize DO
  335.       FOR i2:=1 TO bdsize DO
  336.         board[i1][i2].enemy:=" ";
  337.         board[i1][i2].tf:=" ";
  338.         board[i1][i2].star:=".";
  339.       END;
  340.     END;
  341.  
  342.     PutStr("planet size 1=tiny 2=small 3=medium 4=large 5=giant (default=3)? ");
  343.     GetChar(planetsize);
  344.     IF planetsize#"\n" THEN
  345.       PutCh("\n");
  346.     END;
  347.     IF (planetsize#"1") AND (planetsize#"2") AND
  348.        (planetsize#"4") AND (planetsize#"5") THEN
  349.       planetsize:="3";
  350.     END;
  351.  
  352.     (* init stars *)
  353.     FOR i1:=1 TO nstars DO
  354.       enemyArrival[i1]:=FALSE;
  355.       enemyDepart[i1]:=FALSE;
  356.       playerArrival[i1]:=FALSE;
  357.       REPEAT
  358.         x:=RN.RND(bdsize)+1;
  359.         y:=RN.RND(bdsize)+1;
  360.       UNTIL board[x][y].star=".";
  361.       stars[i1].x:=x;
  362.       stars[i1].y:=y;
  363.  
  364.       FOR i2:=1 TO i1 DO
  365.         IF i1=i2 THEN
  366.           distance[i1][i2]:=0;
  367.         ELSE
  368.           temp:=((x-stars[i2].x)*(x-stars[i2].x))+
  369.                 ((y-stars[i2].y)*(y-stars[i2].y));
  370.  
  371.           (* preset distance to boardsize*sqrt(2) *)
  372.           distance[i1][i2]:=(bdsize*15) DIV 10;
  373.  
  374.           FOR i3:=1 TO (bdsize*15) DIV 10 DO
  375.             IF temp<i3*i3 THEN
  376.               distance[i1][i2]:=i3;
  377.               i3:=bdsize+bdsize; (* exit FOR loop *)
  378.             END;
  379.           END;
  380.           distance[i2][i1]:=distance[i1][i2];
  381.         END;
  382.       END;
  383.  
  384.       FOR team:=ENEMY TO player DO
  385.         tfStars[i1][team]:=0;
  386.         colStars[i1][team]:=0;
  387.       END;
  388.  
  389.       board[x][y].star:=CHAR(IntType("A")+i1-1);
  390.       board[x][y].enemy:="?";
  391.       stars[i1].visit[player]:=FALSE;
  392.       stars[i1].visit[ENEMY]:=FALSE;
  393.       AssignPlanets(stars[i1],i1,planetsize);
  394.     END;
  395.  
  396.     (* initialize research costs *)
  397.     CASE level OF
  398.       |"1": rangeRequired[02]:=3;
  399.       |"2": rangeRequired[02]:=5;
  400.       |"3": rangeRequired[02]:=7;
  401.     END;
  402.     FOR i1:=3 TO maxRange DO
  403.       IF i1<=10 THEN
  404.         rangeRequired[i1]:=IntType(LONGREAL(rangeRequired[i1-1])*resCostFactor)+1;
  405.       ELSE
  406.         rangeRequired[i1]:=IntType(LONGREAL(rangeRequired[i1-1])*(resCostFactor-0.2))+1;
  407.       END;
  408.       IF rangeRequired[i1]>99 THEN
  409.         rangeRequired[i1]:=10*(rangeRequired[i1] DIV 10);
  410.       ELSIF rangeRequired[i1]>999 THEN
  411.         rangeRequired[i1]:=100*(rangeRequired[i1] DIV 100);
  412.       ELSIF rangeRequired[i1]>9999 THEN
  413.         rangeRequired[i1]:=1000*(rangeRequired[i1] DIV 1000);
  414.       END;
  415.     END;
  416.  
  417.     CASE level OF
  418.       |"1": velocityRequired[02]:=30;
  419.       |"2": velocityRequired[02]:=40;
  420.       |"3": velocityRequired[02]:=50;
  421.     END;
  422.     FOR i1:=3 TO maxVelocity DO
  423.       IF i1<=10 THEN
  424.         velocityRequired[i1]:=IntType(LONGREAL(velocityRequired[i1-1])*resCostFactor)+1;
  425.       ELSE
  426.         velocityRequired[i1]:=IntType(LONGREAL(velocityRequired[i1-1])*resCostFactor-0.1)+1;
  427.       END;
  428.       IF velocityRequired[i1]>99 THEN
  429.         velocityRequired[i1]:=10*(velocityRequired[i1] DIV 10);
  430.       ELSIF velocityRequired[i1]>999 THEN
  431.         velocityRequired[i1]:=100*(velocityRequired[i1] DIV 100);
  432.       ELSIF velocityRequired[i1]>9999 THEN
  433.         velocityRequired[i1]:=1000*(velocityRequired[i1] DIV 1000);
  434.       END;
  435.     END;
  436.  
  437.     CASE level OF
  438.       |"1": weaponRequired[2]:=15;
  439.       |"2": weaponRequired[2]:=20;
  440.       |"3": weaponRequired[2]:=25;
  441.     END;
  442.     FOR i1:=3 TO maxWeapons DO
  443.       IF i1<=10 THEN
  444.         weaponRequired[i1]:=IntType(LONGREAL(weaponRequired[i1-1])*(resCostFactor+0.2))+1;
  445.       ELSE
  446.         weaponRequired[i1]:=IntType(LONGREAL(weaponRequired[i1-1])*resCostFactor)+1;
  447.       END;
  448.       IF weaponRequired[i1]>99 THEN
  449.         weaponRequired[i1]:=10*(weaponRequired[i1] DIV 10);
  450.       ELSIF weaponRequired[i1]>999 THEN
  451.         weaponRequired[i1]:=100*(weaponRequired[i1] DIV 100);
  452.       ELSIF weaponRequired[i1]>9999 THEN
  453.         weaponRequired[i1]:=1000*(weaponRequired[i1] DIV 1000);
  454.       END;
  455.     END;
  456.  
  457.     (* initialize task forces *)
  458.     tf[ENEMY][1].x:=1;
  459.     tf[ENEMY][1].y:=1;
  460.     FOR team:=ENEMY TO player DO
  461.       FOR i1:=1 TO 26 DO
  462.         tf[team][i1].dest:=0;
  463.         tf[team][i1].blasting:=FALSE;
  464.         tf[team][i1].withdrew:=FALSE;
  465.         tf[team][i1].s:=0;
  466.         tf[team][i1].t:=0;
  467.         tf[team][i1].c:=0;
  468.         tf[team][i1].b:=0;
  469.         tf[team][i1].dest:=0;
  470.         tf[team][i1].eta:=0;
  471.       END;
  472.       tf[team][1].t:=initunit+20-(INTEGER(level)-48)*10;
  473.       vel[team]:=initvel;
  474.       curRange[team]:=initrange;
  475.       weapons[team]:=initweap;
  476.       weaponResearch[team]:=0;
  477.       velocityResearch[team]:=0;
  478.       rangeResearch[team]:=0;
  479.     END;
  480.     INC(curRange[ENEMY],1+(INTEGER(level)-48));
  481.     growthRate[player]:=initgrowthplayer;
  482.     growthRate[ENEMY]:=initgrowthenemy;
  483.     IF level="3" THEN
  484.       INC(weapons[ENEMY]);
  485.       INC(vel[ENEMY]);
  486.       INC(tf[ENEMY][1].t,10);
  487.       growthRate[ENEMY]:=initgrowthenemy+0.1;
  488.       growthRate[player]:=initgrowthplayer-0.05;
  489.     END;
  490.  
  491.     PutStr("randomize enemy (Y/n)? ");
  492.     GetChar(ch);
  493.     IF ch#"\n" THEN
  494.       PutCh("\n");
  495.     END;
  496.     randomEnemy:=(ch#"n") AND (ch#"N");
  497.  
  498.     IF randomEnemy THEN
  499.       FOR i1:=1 TO 3 DO
  500.         CASE RN.RND(3) OF
  501.           |0: INC(weapons[ENEMY]);
  502.           |1: INC(vel[ENEMY]);
  503.           |2: growthRate[ENEMY]:=growthRate[ENEMY]+0.07;
  504.         END;
  505.       END;
  506.     END;
  507.  
  508.     gameOver:=FALSE;
  509.     turn:=1;
  510.     prodYear:=1;
  511.     PrintMap();
  512.     SetCursorPos(32,20);
  513.     PutStr("* Initialization *  ");
  514.     InitPlayer();
  515.   END InitConstants;
  516.  
  517.  
  518.  
  519. PROCEDURE InitMatch;
  520.   VAR
  521.     resAmount,maxx,startStar,starnum,count: IntType;
  522.     slist: RealStarList;
  523.   BEGIN
  524.     tf[ENEMY][1].c:=1;
  525.     tf[ENEMY][1].s:=2;
  526.  
  527.     enemyResearch:="V";
  528.     resAmount:=2;
  529.     DoResearch(ENEMY,enemyResearch,resAmount);
  530.  
  531.     maxx:=0;
  532.     startStar:=0;
  533.     FOR starnum:=1 TO nstars DO
  534.       GetStars(starnum,slist,count);
  535.       count:=count+RN.RND(5)+1;
  536.       IF count>maxx THEN
  537.         maxx:=count;
  538.         startStar:=starnum;
  539.       END;
  540.     END;
  541.     tf[ENEMY][1].dest:=startStar;
  542.     tf[ENEMY][1].x:=stars[startStar].x;
  543.     tf[ENEMY][1].y:=stars[startStar].y;
  544.     stars[startStar].visit[ENEMY]:=TRUE;
  545.     tfStars[startStar][ENEMY]:=1;
  546.     SetCursorPos(50,1);
  547.     PrintStar(tf[player][1].dest);
  548.     ClearField;
  549.     IF startStar=tf[player][1].dest THEN
  550.       ClearLeft;
  551.       Battle;
  552.     END;
  553.   END InitMatch;
  554.  
  555.  
  556.  
  557. PROCEDURE Depart(starnum: IntType);
  558.   BEGIN
  559.     IF (tfStars[starnum][player]+colStars[starnum][player])>0 THEN
  560.       enemyDepart[starnum]:=TRUE;
  561.     END;
  562.   END Depart;
  563.  
  564.  
  565.  
  566. PROCEDURE UnderDefPlanet(planet: PlanetPtr): BOOLEAN;
  567.   BEGIN
  568.     RETURN (planet^.iu>10) AND ((6*planet^.amb+planet^.mb)<(planet^.iu DIV 2));
  569.   END UnderDefPlanet;
  570.  
  571.  
  572.  
  573. PROCEDURE EvalBCColony(planet: PlanetPtr): IntType;
  574.   VAR
  575.     i,forces: IntType;
  576.     result: IntType;
  577.   BEGIN
  578.     IF NOT stars[planet^.pstar].visit[ENEMY] THEN
  579.       result:=300;
  580.       IF RN.RND(10)<2 THEN
  581.         result:=600;
  582.       END;
  583.     ELSE
  584.       CASE planet^.eSeeTeam OF
  585.         |none:   result:=150+planet^.capacity*2;
  586.         |ENEMY:  IF planet^.conquered THEN
  587.                    result:=200+planet^.capacity*3;
  588.                  ELSIF UnderDefPlanet(planet) THEN
  589.                    result:=200+planet^.capacity*2;
  590.                  ELSE
  591.                    result:=0;
  592.                  END;
  593.         |player: IF planet^.conquered THEN
  594.                    result:=100+planet^.capacity*5;
  595.                  ELSE
  596.                    result:=100+planet^.capacity*4;
  597.                    IF RN.RND(10)<2 THEN
  598.                      result:=result*3;
  599.                    END;
  600.                  END;
  601.       END;
  602.     END;
  603.     result:=result+RN.RND(20)+1;
  604.     RETURN result;
  605.   END EvalBCColony;
  606.  
  607.  
  608.  
  609. PROCEDURE EvalTColony(planet: PlanetPtr; dist: LONGREAL): IntType;
  610.   VAR
  611.     result: IntType;
  612.   BEGIN
  613.     IF NOT stars[planet^.pstar].visit[ENEMY] THEN
  614.       result:=120;
  615.     ELSE
  616.       CASE planet^.eSeeTeam OF
  617.         |none:   result:=planet^.capacity*4;
  618.         |ENEMY:  result:=(planet^.capacity-planet^.inhabitants)*4;
  619.         |player: result:=-10000;
  620.       END;
  621.     END;
  622.     result:=result-IntType(dist+dist+0.5);
  623.     RETURN result;
  624.   END EvalTColony;
  625.  
  626.  
  627.  
  628. PROCEDURE WanderBC(VAR task: TaskForce; VAR slist: RealStarList);
  629.   VAR
  630.     ships,i,count,dest,newTF: IntType;
  631.   BEGIN
  632.     IF (task.b>1) OR (task.c>1) THEN
  633.       count:=0;
  634.       FOR i:=1 TO nstars DO
  635.         IF slist[i]#0.0 THEN
  636.           INC(count);
  637.         END;
  638.       END;
  639.       IF count>0 THEN
  640.         dest:=RN.RND(count)+1;
  641.         count:=0;
  642.         i:=0;
  643.         REPEAT
  644.           INC(i);
  645.           IF slist[i]>0.0 THEN
  646.             INC(count);
  647.           END;
  648.         UNTIL count=dest;
  649.         GetTF(ENEMY,newTF,task.dest);
  650.         ships:=task.b DIV 2;
  651.         tf[ENEMY][newTF].b:=ships;
  652.         task.b:=task.b-ships;
  653.         ships:=task.c DIV 2;
  654.         tf[ENEMY][newTF].c:=ships;
  655.         task.c:=task.c-ships;
  656.  
  657.         IF task.t>3 THEN
  658.           ships:=task.t DIV 2;
  659.           tf[ENEMY][newTF].t:=ships;
  660.           task.t:=task.t-ships;
  661.         END;
  662.  
  663.         tf[ENEMY][newTF].dest:=i;
  664.         tf[ENEMY][newTF].eta:=IntType((slist[i]-0.01) / LONGREAL(vel[ENEMY]))+1;
  665.         Depart(task.dest);
  666.       END;
  667.     END;
  668.   END WanderBC;
  669.  
  670.  
  671.  
  672. PROCEDURE MoveBC(VAR task: TaskForce; VAR slist: RealStarList);
  673.   VAR
  674.     bestStar,topScore,starnum,score,factors: IntType;
  675.     pplanet,bestPlanet: PlanetPtr;
  676.   BEGIN
  677.     IF (task.b>0) OR (task.c>0) THEN
  678.       FOR starnum:=1 TO nstars DO
  679.         IF slist[starnum]>0.0 THEN
  680.           bestStar:=starnum;
  681.           starnum:=nstars+1;
  682.         END;
  683.       END;
  684.  
  685.       bestPlanet:=NIL;
  686.       topScore:=-1000;
  687.       FOR starnum:=1 TO nstars DO
  688.         IF (slist[starnum]>0.0) OR (starnum=task.dest) THEN
  689.           pplanet:=stars[starnum].firstPlanet;
  690.           WHILE pplanet#NIL DO
  691.             score:=EvalBCColony(pplanet);
  692.             IF starnum=task.dest THEN
  693.               score:=score+50;
  694.             END;
  695.             IF (tfStars[starnum][ENEMY]>0) AND (turn<50) THEN
  696.               score:=score-150;
  697.             END;
  698.             IF score>topScore THEN
  699.               topScore:=score;
  700.               bestPlanet:=pplanet;
  701.               bestStar:=starnum;
  702.             END;
  703.             pplanet:=pplanet^.next;
  704.           END;
  705.         END;
  706.       END;
  707.  
  708.       IF bestStar=task.dest THEN
  709.         (* stay put *)
  710.         IF bestPlanet#NIL THEN
  711.           IF (bestPlanet^.team=ENEMY) AND (bestPlanet^.conquered) AND ((bestPlanet^.capacity<30) OR (bestPlanet^.capacity-bestPlanet^.iu>=30)) THEN
  712.             factors:=weapons[ENEMY]*(task.c*cruiserGuns+task.b*battleShipGuns);
  713.             factors:=min(factors,4*bestPlanet^.inhabitants);
  714.             BlastPlanet(stars[bestStar],bestPlanet,factors);
  715.             IF (tfStars[bestPlanet^.pstar][player]>0) OR (colStars[bestPlanet^.pstar][player]>0) THEN
  716.               bestPlanet^.pSeeCapacity:=bestPlanet^.capacity;
  717.             END;
  718.           ELSIF (bestPlanet^.team=ENEMY) AND (bestPlanet^.conquered) THEN
  719.             (* decide whether to split *)
  720.             IF (((task.b>3) OR (task.c>3)) AND (RN.RND(4)=3)) OR (task.b>8) THEN
  721.               WanderBC(task,slist);
  722.             END;
  723.           END;
  724.         END;
  725.       ELSE
  726.         (* move *)
  727.         DEC(tfStars[task.dest][ENEMY]);
  728.         Depart(task.dest);
  729.         task.dest:=bestStar;
  730.         task.eta:=IntType((slist[bestStar]-0.01)/LONGREAL(vel[ENEMY]))+1;
  731.       END;
  732.     END;
  733.   END MoveBC;
  734.  
  735.  
  736.  
  737. PROCEDURE SendTransTF(VAR task: TaskForce; VAR slist: RealStarList; destStar: IntType);
  738.   BEGIN
  739.     Depart(task.dest);
  740.     task.dest:=destStar;
  741.     task.eta:=IntType((slist[destStar]-0.01)/LONGREAL(vel[ENEMY]))+1;
  742.   END SendTransTF;
  743.  
  744.  
  745.  
  746. PROCEDURE UnderDefended(starnum: IntType): BOOLEAN;
  747.   VAR
  748.     pplanet: PlanetPtr;
  749.     result: BOOLEAN;
  750.   BEGIN
  751.     result:=FALSE;
  752.     pplanet:=stars[starnum].firstPlanet;
  753.     WHILE (pplanet#NIL) AND (NOT result) DO
  754.       result:=(pplanet^.team=ENEMY) AND UnderDefPlanet(pplanet);
  755.       pplanet:=pplanet^.next;
  756.     END;
  757.     RETURN(result);
  758.   END UnderDefended;
  759.  
  760.  
  761.  
  762. PROCEDURE Swap(VAR a,b: IntType);
  763.   VAR
  764.     t: IntType;
  765.   BEGIN
  766.     t:=a;
  767.     a:=b;
  768.     b:=t;
  769.   END Swap;
  770.  
  771.  
  772.  
  773. PROCEDURE SendTransports(VAR slist: RealStarList; VAR task: TaskForce);
  774.   VAR
  775.     newTF,toLand,secStar,secScore,bestStar,topScore,score,starnum: IntType;
  776.     xstar: IntType;
  777.     pplan,bestPlan: PlanetPtr;
  778.     trash1,trash2: IntType;
  779.   BEGIN
  780.     IF task.t>0 THEN
  781.       bestStar:=0;
  782.       secStar:=0;
  783.       secScore:=-11000;
  784.       topScore:=-10000;
  785.       bestPlan:=NIL;
  786.       FOR starnum:=1 TO nstars DO
  787.         IF (slist[starnum]>0.0) OR (starnum=task.dest) THEN
  788.           pplan:=stars[starnum].firstPlanet;
  789.           WHILE pplan#NIL DO
  790.             score:=EvalTColony(pplan,slist[starnum]);
  791.             xstar:=starnum;
  792.             IF score>topScore THEN
  793.               Swap(bestStar,xstar);
  794.               Swap(topScore,score);
  795.               bestPlan:=pplan;
  796.             END;
  797.             IF score>secScore THEN
  798.               secScore:=score;
  799.               secStar:=xstar;
  800.             END;
  801.             pplan:=pplan^.next;
  802.           END;
  803.         END;
  804.       END;
  805.  
  806.       IF bestStar=task.dest THEN
  807.         (* land *)
  808.         IF (tfStars[bestStar][player]=0) AND (bestPlan^.team#player) THEN
  809.           trash1:=task.t;
  810.           trash2:=(bestPlan^.capacity-bestPlan^.inhabitants) DIV 3;
  811.           toLand:=min(trash1,trash2);
  812.           IF toLand>0 THEN
  813.             IF bestPlan^.inhabitants=0 THEN
  814.               bestPlan^.team:=ENEMY;
  815.               bestPlan^.eSeeTeam:=ENEMY;
  816.               INC(colStars[bestStar][ENEMY]);
  817.             END;
  818.             bestPlan^.inhabitants:=bestPlan^.inhabitants+toLand;
  819.             bestPlan^.iu:=bestPlan^.iu+toLand;
  820.             task.t:=task.t-toLand;
  821.             SendTransports(slist,task);
  822.           END;
  823.         END;
  824.       ELSE
  825.         (* move *)
  826.         IF (task.t>=10) AND (secStar>0) THEN
  827.           GetTF(ENEMY,newTF,task.dest);
  828.           tf[ENEMY][newTF].t:=task.t DIV 2;
  829.           task.t:=task.t-tf[ENEMY][newTF].t;
  830.           IF (task.c>0) AND (NOT UnderDefended(task.dest)) THEN
  831.             tf[ENEMY][newTF].c:=1;
  832.             DEC(task.c);
  833.           END;
  834.           SendTransTF(tf[ENEMY][newTF],slist,bestStar);
  835.           bestStar:=secStar;
  836.         END;
  837.         GetTF(ENEMY,newTF,task.dest);
  838.         tf[ENEMY][newTF].t:=task.t;
  839.         task.t:=0;
  840.         IF (task.c>0) AND (NOT UnderDefended(task.dest)) THEN
  841.           tf[ENEMY][newTF].c:=1;
  842.           DEC(task.c);
  843.         END;
  844.         SendTransTF(tf[ENEMY][newTF],slist,bestStar);
  845.       END;
  846.     END;
  847.   END SendTransports;
  848.  
  849.  
  850.  
  851. PROCEDURE SendScouts(VAR slist: RealStarList; VAR task: TaskForce);
  852.   VAR
  853.     dest,newTF,j,doind: IntType;
  854.     doable: StarList;
  855.     temp1,temp2: LONGREAL;
  856.   BEGIN
  857.     IF task.s>0 THEN
  858.       doind:=0;
  859.       FOR j:=1 TO nstars DO
  860.         IF (NOT stars[j].visit[ENEMY]) AND (slist[j]>0.0) THEN
  861.           INC(doind);
  862.           doable[doind]:=j;
  863.         END;
  864.       END;
  865.  
  866.       WHILE (doind>0) AND (task.s>0) DO
  867.         GetTF(ENEMY,newTF,task.dest);
  868.         tf[ENEMY][newTF].s:=1;
  869.         dest:=RN.RND(doind)+1;
  870.         tf[ENEMY][newTF].dest:=doable[dest];
  871.         tf[ENEMY][newTF].eta:=IntType((slist[doable[dest]]-0.01)/LONGREAL(vel[ENEMY]))+1;
  872.         Depart(task.dest);
  873.         doable[dest]:=doable[doind];
  874.         DEC(doind);
  875.         DEC(task.s);
  876.       END;
  877.  
  878.       WHILE task.s>0 DO
  879.         REPEAT
  880.           dest:=RN.RND(nstars)+1;
  881.         UNTIL slist[dest]>0.0;
  882.         GetTF(ENEMY,newTF,task.dest);
  883.         tf[ENEMY][newTF].s:=1;
  884.         tf[ENEMY][newTF].dest:=dest;
  885.         temp1:=slist[dest]-0.01;
  886.         temp2:=LONGREAL(vel[ENEMY]);
  887.         tf[ENEMY][newTF].eta:=IntType(temp1/temp2)+1;
  888.         Depart(task.dest);
  889.         DEC(task.s);
  890.       END;
  891.     END;
  892.   END SendScouts;
  893.  
  894.  
  895.  
  896. PROCEDURE InputMatch;
  897.   VAR
  898.     count,tfnum,starnum: IntType;
  899.     slist: RealStarList;
  900.   BEGIN
  901.     FOR tfnum:=1 TO 26 DO
  902.       IF (tf[ENEMY][tfnum].eta=0) AND (tf[ENEMY][tfnum].dest#0) THEN
  903.         starnum:=tf[ENEMY][tfnum].dest;
  904.         GetStars(starnum,slist,count);
  905.         SendScouts(slist,tf[ENEMY][tfnum]);
  906.         SendTransports(slist,tf[ENEMY][tfnum]);
  907.         MoveBC(tf[ENEMY][tfnum],slist);
  908.         ZeroTF(ENEMY,tfnum);
  909.       END;
  910.     END;
  911.   END InputMatch;
  912.  
  913.  
  914.  
  915. PROCEDURE MoveShips;
  916.   VAR
  917.     ratio,prob: LONGREAL;
  918.     there,dx,dy,i: IntType;
  919.     tm: Team;
  920.     pplanet: PlanetPtr;
  921.     any,loss: BOOLEAN;
  922.   BEGIN
  923.     (* clear the board *)
  924.     FOR i:=1 TO 26 DO
  925.       IF (tf[player][i].dest#0) AND (tf[player][i].eta#0) THEN
  926.         board[tf[player][i].x][tf[player][i].y].tf:=" ";
  927.         UpdateBoard(tf[player][i].x,tf[player][i].y,right);
  928.       END;
  929.     END;
  930.  
  931.     (* move ships of both teams *)
  932.     tm:=ENEMY;
  933.     REPEAT
  934.       FOR i:=1 TO 26 DO
  935.         IF (tf[tm][i].dest#0) AND (tf[tm][i].eta#0) THEN
  936.           DEC(tf[tm][i].eta);
  937.           IF (NOT stars[tf[tm][i].dest].visit[tm]) AND (tf[tm][i].eta=0) AND (tm=player) THEN
  938.             ClearLeft();
  939.             SetCursorPos(1,19);
  940.             PutStr("Task force "); PutCh(CHAR(IntType("a")+i-1));
  941.             PutStr(" exploring "); PutCh(CHAR(tf[tm][i].dest+IntType("A")-1));
  942.             PutStr(".\n");
  943.  
  944.             prob:=(tExploreProb+LONGREAL((RN.RND(tExploreVar)+1)*tf[tm][i].t))/100.0;
  945.             IF tf[tm][i].s#0 THEN
  946.               prob:=(sExploreProb+LONGREAL((RN.RND(sExploreVar)+1)*tf[tm][i].s))/100.0;
  947.             END;
  948.             IF tf[tm][i].c#0 THEN
  949.               prob:=(cExploreProb+LONGREAL((RN.RND(cExploreVar)+1)*tf[tm][i].c))/100.0;
  950.             END;
  951.             IF tf[tm][i].b#0 THEN
  952.               prob:=(bExploreProb+LONGREAL((RN.RND(bExploreVar)+1)*tf[tm][i].b))/100.0;
  953.             END;
  954.             IF prob>100.0 THEN
  955.               prob:=100.0;
  956.             END;
  957.  
  958.             loss:=TRUE;
  959.             Lose(tf[tm][i].t,loss,"t",prob);
  960.             Lose(tf[tm][i].s,loss,"s",prob);
  961.             Lose(tf[tm][i].c,loss,"c",prob);
  962.             Lose(tf[tm][i].b,loss,"b",prob);
  963.             IF loss THEN
  964.               PutStr("No ships");
  965.             END;
  966.             PutStr(" destroyed.");
  967.             Pause;
  968.             tf[tm][i].eta:=1;       (* fool zero tf *)
  969.             ZeroTF(tm,i);
  970.             tf[tm][i].eta:=0;       (* fool zero tf *)
  971.           END;
  972.  
  973.           IF tf[tm][i].dest#0 THEN
  974.             IF tm=player THEN
  975.               dx:=stars[tf[tm][i].dest].x;
  976.               dy:=stars[tf[tm][i].dest].y;
  977.               ratio:=1.0-LONGREAL(tf[tm][i].eta)/LONGREAL(tf[tm][i].origeta);
  978.               tf[tm][i].x:=tf[tm][i].xf+IntType(ratio*LONGREAL(dx-tf[tm][i].xf));
  979.               tf[tm][i].y:=tf[tm][i].yf+IntType(ratio*LONGREAL(dy-tf[tm][i].yf));
  980.               IF tf[tm][i].eta=0 THEN
  981.                 pplanet:=stars[tf[tm][i].dest].firstPlanet;
  982.                 WHILE pplanet#NIL DO
  983.                   pplanet^.pSeeCapacity:=pplanet^.capacity;
  984.                   pplanet:=pplanet^.next;
  985.                 END;
  986.                 playerArrival[tf[tm][i].dest]:=TRUE;
  987.                 IF NOT stars[tf[tm][i].dest].visit[tm] THEN
  988.                   board[tf[tm][i].x][tf[tm][i].y].enemy:=" ";
  989.                   UpdateBoard(tf[tm][i].x,tf[tm][i].y,left);
  990.                   stars[tf[tm][i].dest].visit[tm]:=TRUE;
  991.                 END;
  992.               END;
  993.             END;
  994.  
  995.             IF (tm=ENEMY) AND (tf[tm][i].eta=0) THEN
  996.               pplanet:=stars[tf[tm][i].dest].firstPlanet;
  997.               stars[tf[tm][i].dest].visit[ENEMY]:=TRUE;
  998.               WHILE pplanet#NIL DO
  999.                 pplanet^.eSeeTeam:=pplanet^.team;
  1000.                 pplanet:=pplanet^.next;
  1001.               END;
  1002.  
  1003.               IF tfStars[tf[tm][i].dest][ENEMY]>0 THEN
  1004.                 there:=1;
  1005.                 WHILE (there=i) OR
  1006.                       (tf[ENEMY][there].dest#tf[ENEMY][i].dest) OR
  1007.                       (tf[ENEMY][there].eta#0) DO
  1008.                   INC(there);
  1009.                 END;
  1010.                 JoinSilent(ENEMY,tf[ENEMY][i],tf[ENEMY][there]);
  1011.               END;
  1012.  
  1013.               IF (tfStars[tf[tm][i].dest][player]>0) OR (colStars[tf[tm][i].dest][player]>0) THEN
  1014.                 enemyArrival[tf[tm][i].dest]:=TRUE;
  1015.               END;
  1016.             END;
  1017.             IF tf[tm][i].eta=0 THEN
  1018.               INC(tfStars[tf[tm][i].dest][tm]);
  1019.             END;
  1020.           END;
  1021.         END;
  1022.       END;
  1023.       INC(tm);
  1024.     UNTIL tm=none;
  1025.  
  1026.     (* put the good guys on the board *)
  1027.     FOR i:=1 TO 26 DO
  1028.       IF tf[player][i].dest#0 THEN
  1029.         tf[player][i].blasting:=FALSE;
  1030.         dx:=tf[player][i].x;
  1031.         dy:=tf[player][i].y;
  1032.         IF board[dx][dy].tf=" " THEN
  1033.           board[dx][dy].tf:=CHAR(i+IntType("a")-1);
  1034.         ELSIF board[dx][dy].tf#CHAR(i+IntType("a")-1) THEN
  1035.           board[dx][dy].tf:="*";
  1036.         END;
  1037.         UpdateBoard(dx,dy,right);
  1038.       END;;
  1039.     END;
  1040.  
  1041.     any:=FALSE;
  1042.     FOR i:=1 TO nstars DO
  1043.       IF playerArrival[i] THEN
  1044.         IF NOT any THEN
  1045.           SetCursorPos(32,21);
  1046.           PutStr("Player arrivals :               ");
  1047.           SetCursorPos(50,21);
  1048.           any:=TRUE;
  1049.         END;
  1050.         PutCh(CHAR(i+IntType("A")-1));
  1051.         playerArrival[i]:=FALSE;
  1052.       END;
  1053.     END;
  1054.  
  1055.     IF NOT any THEN
  1056.       SetCursorPos(32,21);
  1057.       PutStr(blankLine);
  1058.     END;
  1059.  
  1060.     any:=FALSE;
  1061.     FOR i:=1 TO nstars DO
  1062.       IF enemyArrival[i] THEN
  1063.         IF NOT any THEN
  1064.           SetCursorPos(32,22);
  1065.           PutStr("Enemy arrivals  :               ");
  1066.           SetCursorPos(50,22);
  1067.           any:=TRUE;
  1068.         END;
  1069.         PutCh(CHAR(i+IntType("A")-1));
  1070.         enemyArrival[i]:=FALSE;
  1071.       END;
  1072.     END;
  1073.     IF NOT any THEN
  1074.       SetCursorPos(32,22);
  1075.       PutStr(blankLine);
  1076.     END;
  1077.  
  1078.     any:=FALSE;
  1079.     FOR i:=1 TO nstars DO
  1080.       IF enemyDepart[i] THEN
  1081.         IF NOT any THEN
  1082.           SetCursorPos(32,23);
  1083.           PutStr("Enemy departures:               ");
  1084.           SetCursorPos(50,23);
  1085.           any:=TRUE;
  1086.         END;
  1087.         PutCh(CHAR(i+IntType("A")-1));
  1088.         enemyDepart[i]:=FALSE;
  1089.       END;
  1090.     END;
  1091.     IF NOT any THEN
  1092.       SetCursorPos(32,23);
  1093.       PutStr(blankLine);
  1094.     END;
  1095.     FOR i:=1 TO nstars DO
  1096.       Revolt(i);
  1097.     END;
  1098.   END MoveShips;
  1099.  
  1100.  
  1101.  
  1102. PROCEDURE Blast;
  1103.   VAR
  1104.     tfCh,plCh: CHAR;
  1105.     tfNum,planetNum: IntType;
  1106.     pplanet: PlanetPtr;
  1107.     factors,starnum: IntType;
  1108.     done: BOOLEAN;
  1109.     iline: Line;
  1110.     ind,amount: IntType;
  1111.     dum: CHAR;
  1112.   BEGIN
  1113.     PutStr("last");
  1114.     ClearLeft();
  1115.     SetCursorPos(1,19);
  1116.     PutStr("Firing TF:");
  1117.     GetChar(tfCh);
  1118.     tfNum:=IntType(tfCh)-IntType("A")+1;
  1119.     IF (tfNum<1) OR (tfNum>26) THEN
  1120.       ErrorMessage();
  1121.       PutStr(" !Illegal tf");
  1122.     ELSIF tf[player][tfNum].dest=0 THEN
  1123.       ErrorMessage();
  1124.       PutStr(" !Nonexistant tf");
  1125.     ELSIF tf[player][tfNum].eta#0 THEN
  1126.       ErrorMessage();
  1127.       PutStr(" !Tf is not in normal space   ");
  1128.     ELSIF tf[player][tfNum].blasting THEN
  1129.       ErrorMessage();
  1130.       PutStr(" !Tf is already blasting     ");
  1131.     ELSIF (tf[player][tfNum].b=0) AND (tf[player][tfNum].c=0) THEN
  1132.       ErrorMessage();
  1133.       PutStr(" !Tf has no warships         ");
  1134.     ELSE
  1135.       starnum:=tf[player][tfNum].dest;
  1136.       pplanet:=stars[starnum].firstPlanet;
  1137.       IF pplanet=NIL THEN
  1138.         ErrorMessage();
  1139.         PutStr(" !No planets at star "); PutCh(CHAR(starnum+IntType("A")-1));
  1140.         PutStr("       ");
  1141.       ELSE
  1142.         SetCursorPos(1,20);
  1143.         PutStr("Target colony");
  1144.         IF pplanet^.next=NIL THEN
  1145.           PutInt(pplanet^.number,2);
  1146.         ELSE
  1147.           PutStr(": ");
  1148.           GetChar(plCh);
  1149.           planetNum:=IntType(plCh)-IntType("0");
  1150.           REPEAT
  1151.             IF pplanet^.number=planetNum THEN
  1152.               done:=TRUE;
  1153.             ELSE
  1154.               IF pplanet^.next=NIL THEN
  1155.                 done:=TRUE;
  1156.               ELSE
  1157.                 pplanet:=pplanet^.next;
  1158.                 done:=FALSE;
  1159.               END;
  1160.             END;
  1161.           UNTIL done;
  1162.           IF pplanet^.number#planetNum THEN
  1163.             ErrorMessage();
  1164.             PutStr(" !No such planet at this star ");
  1165.             pplanet:=NIL;
  1166.           END;
  1167.         END;
  1168.         IF pplanet#NIL THEN
  1169.           IF pplanet^.team=ENEMY THEN
  1170.             ErrorMessage();
  1171.             PutStr(" !conquer it first!");
  1172.           ELSIF (pplanet^.team=player) AND (NOT pplanet^.conquered) THEN
  1173.             ErrorMessage();
  1174.             PutStr(" !it's a human colony         ");
  1175.           ELSE
  1176.             factors:=weapons[player]*((tf[player][tfNum].c*cruiserGuns)+(tf[player][tfNum].b*battleShipGuns));
  1177.             SetCursorPos(1,21);
  1178.             PutStr("Units (max "); PutInt(factors DIV 4,0); PutStr("): ");
  1179. (*
  1180.             SetCursorPos(19,21);
  1181. *)
  1182.             GetLine(iline,ind,FALSE);
  1183.             GetToken(iline,ind,amount,dum);
  1184.             IF amount<0 THEN
  1185.               factors:=0;
  1186.             ELSIF amount>0 THEN
  1187.               factors:=min(factors,amount*4);
  1188.             END;
  1189.  
  1190.             tf[player][tfNum].blasting:=TRUE;
  1191.             SetCursorPos(1,22);
  1192.             PutStr("Blasting "); PutInt(factors DIV 4,0); PutStr(" units");
  1193.             BlastPlanet(stars[starnum],pplanet,factors);
  1194.             SetCursorPos(1,23);
  1195.             PutCh(CHAR(pplanet^.pstar+IntType("A")-1));
  1196.             pplanet^.pSeeCapacity:=pplanet^.capacity;
  1197.  
  1198.             PrintPlanet(pplanet,TRUE);
  1199.           END;
  1200.         END;
  1201.       END;
  1202.     END;
  1203.   END Blast;
  1204.  
  1205.  
  1206.  
  1207. PROCEDURE LandTransports;
  1208.   VAR
  1209.     tfc,trc,planc: CHAR;
  1210.     x,y,roomLeft,tfnum,transports,planetNum: IntType;
  1211.     starnum,ind: IntType;
  1212.     iline: Line;
  1213.     found: BOOLEAN;
  1214.     pplanet: PlanetPtr;
  1215.   BEGIN
  1216.     PutStr("and tf:");
  1217.     GetChar(tfc);
  1218.     ClearLeft();
  1219.     tfnum:=IntType(tfc)-IntType("A")+1;
  1220.     IF (tfnum<1) OR (tfnum>26) THEN
  1221.       ErrorMessage();
  1222.       PutStr("  !illegal tf");
  1223.     ELSIF tf[player][tfnum].dest=0 THEN
  1224.       ErrorMessage();
  1225.       PutStr("  !nonexistent tf");
  1226.     ELSIF tf[player][tfnum].eta#0 THEN
  1227.       ErrorMessage();
  1228.       PutStr("  !tf is not in normal space  ");
  1229.     ELSE
  1230.       starnum:=tf[player][tfnum].dest;
  1231.       pplanet:=stars[starnum].firstPlanet;
  1232.       IF pplanet=NIL THEN
  1233.         ErrorMessage();
  1234.         PutStr("  !no planets at this star    ");
  1235.       ELSIF tfStars[starnum][ENEMY]>0 THEN
  1236.         ErrorMessage();
  1237.         PutStr("  !enemy ships present");
  1238.       ELSE
  1239.         SetCursorPos(11,18);
  1240.         PutStr(" planet ");
  1241.         IF pplanet^.next=NIL THEN
  1242.           planetNum:=pplanet^.number;
  1243.           PutInt(planetNum,1);
  1244.         ELSE
  1245.           PutStr(":");
  1246.           GetChar(planc);
  1247.           planetNum:=IntType(planc)-IntType("0");
  1248.           found:=FALSE;
  1249.           WHILE (pplanet#NIL) AND (NOT found) DO
  1250.             IF pplanet^.number=planetNum THEN
  1251.               found:=TRUE;
  1252.             ELSE
  1253.               pplanet:=pplanet^.next;
  1254.             END;
  1255.           END;
  1256.           IF NOT found THEN
  1257.             planetNum:=0;
  1258.             ErrorMessage();
  1259.             PutStr(" !Not a habitable planet ");
  1260.           END;
  1261.         END;
  1262.         IF planetNum#0 THEN
  1263.           IF (pplanet^.team=ENEMY) OR ((pplanet^.team=player) AND (pplanet^.conquered)) THEN
  1264.             ErrorMessage();
  1265.             PutStr(" !Enemy colony on the planet  ");
  1266.           ELSE
  1267.             (* get the number of transports *)
  1268.             roomLeft:=pplanet^.capacity-pplanet^.inhabitants;
  1269.             SetCursorPos(1,19);
  1270.             PutStr(" transports:");
  1271.             GetLine(iline,ind,FALSE);
  1272.             GetToken(iline,ind,transports,trc);
  1273.             IF transports=0 THEN
  1274.               transports:=tf[player][tfnum].t;
  1275.             END;
  1276.             IF transports<1 THEN
  1277.               ErrorMessage();
  1278.               PutStr("  !illegal transports");
  1279.             ELSIF transports>tf[player][tfnum].t THEN
  1280.               ErrorMessage();
  1281.               PutStr("  !only "); PutInt(tf[player][tfnum].t,0);
  1282.               PutStr(" transports in tf");
  1283.             ELSIF transports>roomLeft THEN
  1284.               ErrorMessage();
  1285.               PutStr("  !only room for "); PutInt(roomLeft,0);
  1286.               PutStr(" transports");
  1287.             ELSE
  1288.               pplanet^.team:=player;
  1289.               IF pplanet^.inhabitants=0 THEN
  1290.                 INC(colStars[starnum][player]);
  1291.               END;
  1292.               pplanet^.inhabitants:=pplanet^.inhabitants+transports;
  1293.               pplanet^.iu:=pplanet^.iu+transports;
  1294.               tf[player][tfnum].t:=tf[player][tfnum].t-transports;
  1295.               x:=tf[player][tfnum].x;
  1296.               y:=tf[player][tfnum].y;
  1297.               IF board[x][y].enemy=" " THEN
  1298.                 board[x][y].enemy:="@";
  1299.                 UpdateBoard(x,y,left);
  1300.               END;
  1301.               SetCursorPos(1,20);
  1302.               PutCh(CHAR(starnum+IntType("A")-1));
  1303.               PrintPlanet(pplanet,TRUE);
  1304.               ZeroTF(player,tfnum);
  1305.               PrintTF(tfnum);
  1306.             END;
  1307.           END;
  1308.         END;
  1309.       END;
  1310.     END;
  1311.   END LandTransports;
  1312.  
  1313.  
  1314.  
  1315. PROCEDURE SendTF;
  1316.   VAR
  1317.     tfCh: CHAR;
  1318.     tfNum: IntType;
  1319.     error: BOOLEAN;
  1320.   BEGIN
  1321.     PutStr("estination tf: ");
  1322.     GetChar(tfCh);
  1323.     ClearLeft();
  1324.     SetCursorPos(1,19);
  1325.     tfNum:=IntType(tfCh)-IntType("A")+1;
  1326.     IF (tfNum<1) OR (tfNum>26) THEN
  1327.       ErrorMessage();
  1328.       PutStr(" !illegal tf");
  1329.     ELSIF tf[player][tfNum].dest=0 THEN
  1330.       ErrorMessage();
  1331.       PutStr(" !nonexistent tf");
  1332.     ELSIF (tf[player][tfNum].eta#0) AND
  1333.           ((tf[player][tfNum].eta#tf[player][tfNum].origeta) OR tf[player][tfNum].withdrew) THEN
  1334.       ErrorMessage();
  1335.       PutStr(" !tf is not in normal space  ");
  1336.     ELSIF tf[player][tfNum].blasting THEN
  1337.       ErrorMessage();
  1338.       PutStr(" !tf is blasting a planet");
  1339.     ELSE
  1340.       tf[player][tfNum].withdrew:=FALSE;
  1341.       SetDestination(tfNum,error);
  1342.     END;
  1343.   END SendTF;
  1344.  
  1345.  
  1346.  
  1347. PROCEDURE QuitGame;
  1348.   VAR
  1349.     answer: CHAR;
  1350.   BEGIN
  1351.     ClearScreen;
  1352.     PutStr("Quit game... are you sure (y/N)? ");
  1353.     GetChar(answer);
  1354.     IF answer#"Y" THEN
  1355.       PrintMap;
  1356.     ELSE
  1357.       gameOver:=TRUE;
  1358.     END;
  1359.   END QuitGame;
  1360.  
  1361.  
  1362.  
  1363. PROCEDURE InputPlayer;
  1364.   VAR
  1365.     key: CHAR;
  1366.     fin: BOOLEAN;
  1367.   BEGIN
  1368.     SetCursorPos(32,20);
  1369.     PutStr("* Movement *        ");
  1370.     fin:=FALSE;
  1371.     REPEAT
  1372.       SetCursorPos(1,18);
  1373.       PutStr("?                             ");
  1374.       SetCursorPos(3,18);
  1375.       GetChar(key);
  1376.       CASE key OF
  1377.         |"M": PrintMap;
  1378.         |"B": Blast;
  1379.         |"G",
  1380.          " ": fin:=TRUE;
  1381.         |"H": Help(1);
  1382.         |"L": LandTransports;
  1383.         |"D": SendTF();
  1384.         |"S": StarSummary();
  1385.         |"N": MakeTF;
  1386.         |"J": JoinTF();
  1387.         |"C": PrintColony();
  1388.         |"R": ResearchSummary();
  1389.         |"Q": fin:=TRUE;
  1390.               QuitGame;
  1391.         |"?":
  1392.         |"T": TFSummary();
  1393.         |ELSE ErrorMessage();
  1394.               PutStr("  !illegal command");
  1395.       END;
  1396.     UNTIL fin;
  1397.   END InputPlayer;
  1398.  
  1399.  
  1400.  
  1401. PROCEDURE InvestEnemy(x,y: IntType; planet: PlanetPtr);
  1402.   VAR
  1403.     num,invAmount,balance,minMB,transports,newTF: IntType;
  1404.     trash1,trash2: IntType;
  1405.   BEGIN
  1406.     balance:=planet^.iu;
  1407.     IF tfStars[planet^.pstar][ENEMY]=0 THEN
  1408.       GetTF(ENEMY,newTF,planet^.pstar);
  1409.       tfStars[planet^.pstar][ENEMY]:=1;
  1410.     ELSE
  1411.       (* use present tf *)
  1412.       newTF:=1;
  1413.       WHILE (tf[ENEMY][newTF].dest#planet^.pstar) OR (tf[ENEMY][newTF].eta#0) DO
  1414.         INC(newTF);
  1415.       END;
  1416.     END;
  1417.     minMB:=planet^.capacity DIV 20;
  1418.     WHILE (planet^.amb=0) AND (NOT planet^.conquered) AND (planet^.mb<minMB) AND (balance>=mbCost) AND (balance<ambCost) DO
  1419.       balance:=balance-mbCost;
  1420.       INC(planet^.mb);
  1421.     END;
  1422.     WHILE (balance>=battleShipCost) AND (RN.RND(5)>1) AND (NOT UnderDefPlanet(planet)) DO
  1423.       balance:=balance-battleShipCost;
  1424.       INC(tf[ENEMY][newTF].b);
  1425.     END;
  1426.     WHILE (balance>=ambCost) AND UnderDefPlanet(planet) AND (NOT planet^.conquered) DO
  1427.       balance:=balance-ambCost;
  1428.       INC(planet^.amb);
  1429.     END;
  1430.     WHILE balance>=9 DO
  1431.        CASE RN.RND(15) OF
  1432.         |1,2,
  1433.          3,4: DoResearch(ENEMY,enemyResearch,9);
  1434.               balance:=balance-9;
  1435.  
  1436.         |5:   IF balance>=cruiserCost THEN
  1437.                 balance:=balance-cruiserCost;
  1438.                 INC(tf[ENEMY][newTF].c);
  1439.               ELSIF (NOT planet^.conquered) AND (balance>=mbCost) THEN
  1440.                 balance:=balance-mbCost;
  1441.                 INC(planet^.mb);
  1442.               ELSE
  1443.                 balance:=balance-9;
  1444.                 DoResearch(ENEMY,enemyResearch,9);
  1445.               END;
  1446.  
  1447.         |6,7,
  1448.          8:   IF ((planet^.inhabitants DIV planet^.capacity>=1) AND
  1449.                   (planet^.inhabitants<IntType(LONGREAL(planet^.capacity)*growthRate[planet^.team])-1) AND
  1450.                   (NOT planet^.conquered))
  1451.                  OR
  1452.                   (NOT ((LONGREAL(planet^.inhabitants)/LONGREAL(planet^.capacity)<0.6) OR (planet^.capacity*iuRatio>=battleShipCost)))
  1453.                  OR
  1454.                   ((planet^.iu<battleShipCost) AND (planet^.capacity<battleShipCost) AND (RN.RND(10)<7))
  1455.                  OR
  1456.                   ((turn<100) AND (RN.RND(10)<8))
  1457.               THEN
  1458.                 (* build transports *)
  1459.                 transports:=min(balance,planet^.inhabitants-planet^.capacity+1);
  1460.                 IF transports<0 THEN
  1461.                   transports:=min(4+RN.RND(5),planet^.inhabitants DIV 2);
  1462.                 END;
  1463.                 balance:=balance-transports;
  1464.                 planet^.inhabitants:=planet^.inhabitants-transports;
  1465.                 trash1:=planet^.iu-transports;
  1466.                 trash2:=planet^.inhabitants*iuRatio;
  1467.                 planet^.iu:=min(trash1,trash2);
  1468.                 tf[ENEMY][newTF].t:=tf[ENEMY][newTF].t+transports;
  1469.               ELSE
  1470.                 (* no transports *)
  1471.                 WHILE (balance>=9) AND (planet^.inhabitants*iuRatio-planet^.iu>0) DO
  1472.                   invAmount:=min(3,planet^.inhabitants*iuRatio-planet^.iu);
  1473.                   balance:=balance-invAmount*investCost;
  1474.                   planet^.iu:=planet^.iu+invAmount;
  1475.                 END;
  1476.               END;
  1477.         |9:   IF RN.RND(10)<5 THEN
  1478.                 balance:=balance-scoutCost;
  1479.                 INC(tf[ENEMY][newTF].s);
  1480.               ELSE
  1481.                 DoResearch(ENEMY,enemyResearch,9);
  1482.                 balance:=balance-9;
  1483.               END;
  1484.         |ELSE invAmount:=min(3,planet^.inhabitants*iuRatio-planet^.iu);
  1485.               balance:=balance-investCost*invAmount;
  1486.               planet^.iu:=planet^.iu+invAmount;
  1487.       END;
  1488.     END;
  1489.     ZeroTF(ENEMY,newTF);
  1490.     DoResearch(ENEMY,enemyResearch,balance);
  1491.   END InvestEnemy;
  1492.  
  1493.  
  1494.  
  1495. PROCEDURE InvestPlayer(x,y: IntType; planet: PlanetPtr);
  1496.   VAR
  1497.     printTaskForce: BOOLEAN;
  1498.     iline: Line;
  1499.     key: CHAR;
  1500.     cost,amount,ind,newTF,balance: IntType;
  1501.     trash1,trash2: IntType;
  1502.   BEGIN
  1503.     GetTF(player,newTF,planet^.pstar);
  1504.     INC(tfStars[planet^.pstar][player]);
  1505.     printTaskForce:=FALSE;
  1506.     balance:=planet^.iu;
  1507.     ClearLeft();
  1508.     SetCursorPos(1,19);
  1509.     PutCh(CHAR(planet^.pstar+IntType("A")-1));
  1510.  
  1511.     PrintPlanet(planet,TRUE);
  1512.  
  1513.     REPEAT
  1514.       SetCursorPos(1,18);
  1515.       PutInt(balance,3); PutStr("?                          ");
  1516.       SetCursorPos(6,18);
  1517.       GetLine(iline,ind,FALSE);
  1518.       REPEAT
  1519.         GetToken(iline,ind,amount,key);
  1520.         CASE key OF
  1521.           |"A": cost:=amount*ambCost;
  1522.                 IF planet^.inhabitants=0 THEN
  1523.                   cost:=0;
  1524.                   ErrorMessage();
  1525.                   PutStr(" !abandoned planet");
  1526.                 ELSIF planet^.conquered THEN
  1527.                   cost:=0;
  1528.                   ErrorMessage();
  1529.                   PutStr(" !No amb on conquered colony ");
  1530.                 ELSE
  1531.                   IF cost<=balance THEN
  1532.                     planet^.amb:=planet^.amb+amount;
  1533.                   END;
  1534.                 END;
  1535.           |"B": cost:=amount*battleShipCost;
  1536.                 IF cost<=balance THEN
  1537.                   tf[player][newTF].b:=tf[player][newTF].b+amount;
  1538.                   printTaskForce:=TRUE;
  1539.                 END;
  1540.           |"C": cost:=amount*cruiserCost;
  1541.                 IF cost<=balance THEN
  1542.                   tf[player][newTF].c:=tf[player][newTF].c+amount;
  1543.                   printTaskForce:=TRUE;
  1544.                 END;
  1545.           |"H": Help(4);
  1546.                 cost:=0;
  1547.           |"M": cost:=amount*mbCost;
  1548.                 IF planet^.inhabitants=0 THEN
  1549.                   cost:=0;
  1550.                   ErrorMessage();
  1551.                   PutStr(" !abandoned planet");
  1552.                 ELSIF planet^.conquered THEN
  1553.                   cost:=0;
  1554.                   ErrorMessage();
  1555.                   PutStr(" !no mb on conquered colony  ");
  1556.                 ELSE
  1557.                   IF cost<=balance THEN
  1558.                     planet^.mb:=planet^.mb+amount;
  1559.                   END;
  1560.                 END;
  1561.           |"S": cost:=amount*scoutCost;
  1562.                 IF cost<=balance THEN
  1563.                   tf[player][newTF].s:=tf[player][newTF].s+amount;
  1564.                   printTaskForce:=TRUE;
  1565.                 END;
  1566.           |"T": cost:=amount;
  1567.                 IF cost<=balance THEN
  1568.                   IF cost>planet^.inhabitants THEN
  1569.                     ErrorMessage();
  1570.                     PutStr(" !not enough people for trans");
  1571.                     cost:=0;
  1572.                   ELSIF planet^.conquered THEN
  1573.                     cost:=0;
  1574.                     ErrorMessage();
  1575.                     PutStr(" !No transp. on conqered col.");
  1576.                   ELSE
  1577.                     tf[player][newTF].t:=tf[player][newTF].t+amount;
  1578.                     planet^.inhabitants:=planet^.inhabitants-amount;
  1579.                     trash1:=planet^.iu-amount;
  1580.                     trash2:=planet^.inhabitants*iuRatio;
  1581.                     planet^.iu:=min(trash1,trash2);
  1582.                     printTaskForce:=TRUE;
  1583.                     IF planet^.inhabitants=0 THEN
  1584.                       DEC(colStars[planet^.pstar][player]);
  1585.                       IF colStars[planet^.pstar][player]=0 THEN
  1586.                         board[x][y].enemy:=" ";
  1587.                         UpdateBoard(x,y,left);
  1588.                       END;
  1589.                       planet^.team:=none;
  1590.                       planet^.amb:=0;
  1591.                       planet^.mb:=0;
  1592.                       planet^.iu:=0;
  1593.                     END;
  1594.                   END;
  1595.                 END;
  1596.           |"I": cost:=investCost*amount;
  1597.                 IF (amount+planet^.iu)>(planet^.inhabitants*iuRatio) THEN
  1598.                   cost:=0;
  1599.                   ErrorMessage();
  1600.                   PutStr(" !Can't support that many iu's");
  1601.                 ELSIF cost<=balance THEN
  1602.                   planet^.iu:=planet^.iu+amount;
  1603.                 END;
  1604.           |"R",
  1605.            "V",
  1606.            "W": cost:=amount;
  1607.                 IF cost<=balance THEN
  1608.                   SetCursorPos(1,21);
  1609.                   DoResearch(player,key,amount);
  1610.                 END;
  1611.                 ResearchSummary;
  1612.           |" ": cost:=0;
  1613.           |">": cost:=0;
  1614.                 SetCursorPos(1,18);
  1615.                 PutStr(">?     ");
  1616.                 SetCursorPos(4,18);
  1617.                 GetChar(key);
  1618.                 CASE key OF
  1619.                   |"M": PrintMap();
  1620.                   |"S": StarSummary();
  1621.                   |"C": PrintColony();
  1622.                   |"R": ResearchSummary();
  1623.                   |ELSE ErrorMessage();
  1624.                         PutStr(" !only M,S,C,R allowed      ");
  1625.                 END;
  1626.           |ELSE ErrorMessage();
  1627.                 PutStr(" !illegal field "); PutCh(key);
  1628.         END;
  1629.         IF cost>balance THEN
  1630.           ErrorMessage();
  1631.           PutStr(" !can't afford "); PutInt(amount,0); PutCh(key);
  1632.         ELSE
  1633.           balance:=balance-cost;
  1634.         END;
  1635.       UNTIL key=" ";
  1636.       ClearLeft();
  1637.       SetCursorPos(1,19);
  1638.       PutCh(CHAR(planet^.pstar+IntType("A")-1));
  1639.  
  1640.       PrintPlanet(planet,TRUE);
  1641.  
  1642.       IF printTaskForce THEN
  1643.         SetCursorPos(1,20);
  1644.         PrintTF(newTF);
  1645.       END;
  1646.     UNTIL balance<=0;
  1647.     ZeroTF(player,newTF);
  1648.     OnBoard(x,y);
  1649.   END InvestPlayer;
  1650.  
  1651.  
  1652.  
  1653. PROCEDURE Invest;
  1654.   VAR
  1655.     newborn,starnum: IntType;
  1656.     pplan: PlanetPtr;
  1657.   BEGIN
  1658.     prodYear:=0;
  1659.     SetCursorPos(32,20);
  1660.     PutStr("* investment *      ");
  1661.     FOR starnum:=1 TO nstars DO
  1662.       pplan:=stars[starnum].firstPlanet;
  1663.       WHILE pplan#NIL DO
  1664.         IF (pplan^.eSeeTeam=player) AND (pplan^.capacity>10) AND (pplan^.eSeeDefend<12) THEN
  1665.           INC(pplan^.eSeeDefend);
  1666.         END;
  1667.         IF pplan^.team#none THEN
  1668.           IF pplan^.inhabitants<pplan^.capacity THEN
  1669.             newborn:=IntType(LONGREAL(pplan^.inhabitants)*growthRate[pplan^.team]+0.9);
  1670.           ELSE
  1671.             newborn:=0;
  1672.           END;
  1673.           IF pplan^.conquered THEN
  1674.             newborn:=newborn DIV 2;
  1675.           END;
  1676.           pplan^.inhabitants:=pplan^.inhabitants+newborn;
  1677.           pplan^.iu:=pplan^.iu+newborn;
  1678.           IF pplan^.team=ENEMY THEN
  1679.             InvestEnemy(stars[starnum].x,stars[starnum].y,pplan);
  1680.           ELSE
  1681.             InvestPlayer(stars[starnum].x,stars[starnum].y,pplan);
  1682.           END;
  1683.         END;
  1684.         pplan:=pplan^.next;
  1685.       END;
  1686.     END;
  1687.     Battle;
  1688.   END Invest;
  1689.  
  1690.  
  1691.  
  1692. BEGIN
  1693.   vers:=version;
  1694.   rawFile:=DosL.Open(SYSTEM.ADR("RAW:0/0/1000/800/CONQUEST 2.3 by JOW"),DosD.newFile);
  1695.   IF rawFile=NIL THEN
  1696.     rawFile:=DosL.Open(SYSTEM.ADR("RAW:0/0/640/512/CONQUEST 2.3 by JOW"),DosD.newFile);
  1697.   END;
  1698.   IF rawFile=NIL THEN
  1699.     rawFile:=DosL.Open(SYSTEM.ADR("RAW:0/0/600/380/CONQUEST 2.3 by JOW"),DosD.newFile);
  1700.   END;
  1701.   IF rawFile=NIL THEN
  1702.     rawFile:=DosL.Open(SYSTEM.ADR("RAW:0/0/600/180/CONQUEST 2.3 by JOW"),DosD.newFile);
  1703.   END;
  1704.   IF rawFile=NIL THEN
  1705.     rawFile:=DosL.Open(SYSTEM.ADR("RAW:0/0/300/100/CONQUEST 2.3 by JOW"),DosD.newFile);
  1706.   END;
  1707.   IF rawFile=NIL THEN
  1708.     rawFile:=DosL.Open(SYSTEM.ADR("RAW:0/0/150/100/CONQUEST 2.3 by JOW"),DosD.newFile);
  1709.   END;
  1710.   IF rawFile#NIL THEN
  1711.     CursorOff;
  1712.     PutStr("\n *** CONQUEST V2.3 *** \n");
  1713.     InitConstants;
  1714.     InitMatch;
  1715.     REPEAT
  1716.       InputPlayer;
  1717.       IF NOT gameOver THEN
  1718.         InputMatch;
  1719.         MoveShips;
  1720.         Battle;
  1721.         IF (prodYear=4) AND (turn<maxTurns) THEN
  1722.           Invest;
  1723.         END;
  1724.         NextYear;
  1725.       END;
  1726.       CheckGameOver();
  1727.     UNTIL gameOver;
  1728.     Pause;
  1729.     CursorOn;
  1730.   END;
  1731. CLOSE
  1732.   IF rawFile#NIL THEN
  1733.     DosL.Close(rawFile);
  1734.   END;
  1735. END Conquest.
  1736.